package com.caishi.lkx.exam.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.caishi.lkx.common.BaseApi;
import com.caishi.lkx.common.role.Roles;
import com.caishi.lkx.exam.model.WeekRankModel;
import com.caishi.lkx.exam.service.IWeekRankService;
import com.caishi.lkx.exam.vo.WeekRankVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Tag(name = "每周排行相关接口")
@Slf4j
@RestController
@RequestMapping("/exam/week-rank")
public class WeekRankApi extends BaseApi {

    @Resource
    private IWeekRankService weekRankService;

    @Roles
    @GetMapping("/index")
    @Operation(summary = "获取每周排行")
    public IPage<WeekRankVo> rank(@ModelAttribute Page<WeekRankModel> page, @RequestParam Long categoryId) {
        page.setSearchCount(false);
        return weekRankService.getWeekRank(page, categoryId);
    }
}
